package org.lzfto.flink.demo.business.flinkTest.flinkObjects.source.mqtt;

import java.nio.charset.StandardCharsets;

import org.apache.flink.api.connector.source.SourceSplit;

public class MqttSplit implements SourceSplit {
    private final String splitId;
    private final String topic;
    private final int qos;
    private final String clientId;

    public MqttSplit(String splitId, String topic, int qos, String clientId) {
        this.splitId = splitId;
        this.topic = topic;
        this.qos = qos;
        this.clientId = clientId;
    }

    @Override
    public String splitId() {
        return splitId;
    }

    public String getTopic() {
        return topic;
    }

    public int getQos() {
        return qos;
    }

    public String getClientId() {
        return clientId;
    }

    @Override
    public String toString() {
        return "MqttSplit{" +
                "splitId='" + splitId + '\'' +
                ", topic='" + topic + '\'' +
                ", qos=" + qos +
                ", clientId='" + clientId + '\'' +
                '}';
    }

    public byte[] serialize() {
        return toString().getBytes(StandardCharsets.UTF_8);
    }
}